<template>
	    <view class='main'>
	    	<navbar  :btnColors='btnColor' title="我的团员" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
			<view>
			
			<view class="flex groups_title">
				<text>总数：{{group_total}}</text>
			</view>
			  <swiper class="tab-content"  duration="300" bindchange="changeTab" :style="{'height':winHeight+'px'}">
					<!-- 全部 -->
					<swiper-item>
						<scroll-view :scroll-y="true" class="new-list-box" @scrolltolower="allLoadMore" scroll-top="scrollTop" scroll-with-animation :refresher-enabled="true" refresher-threshold="80" refresher-default-style="white" refresher-background="white" :refresher-triggered="triggered" @refresherrefresh="onAllRefresh">
							<block v-if="allTabList.length > 0">
								<view class="new-list-item" v-for="(item,index) in allTabList" :key="index">                        
									<view class="flex item-tag" style="width: 70px;">                    
									   <image class="mine__bg--avatar" style="background:" :src="item.wx_icon?userInfo.wx_icon:'/static/mine/avatar.png'" @click="setBase()"></image>											                  
									</view>
									<view class="flex item-tag  justify-between border-b mr-20 pb-30" style="width: 80%;">
										 <view class="content-deadline" style="color: #222222;font-size: 28rpx;">{{item.phone}}</view>          
										<view class="content-deadline" style="color: #888888;font-size: 28rpx;">{{item.create_time}}</view>
								  </view>
								</view>
							</block>                
						</scroll-view>
					</swiper-item>       
				</swiper>				
			</view>
		</view>
</template>

<script>
	export default {
		data() {
			return {
					...getApp().globalData.config,
				cashType:'',
				userInfo:{},
				winHeight:0,
				pageNo:1,
				allTabList:[], // 全部  
				currentTab: 1, // 当前所在滑块的 index
				scrollTop: 0, // 设置竖向滚动条位置
				triggered: false, // 下拉是否激活
				group_total:0, 
			};
		},
		
		onLoad(options){
			let that=this
			if(options.cashType){
			  this.cashType=options.cashType			  
			}
			let height = uni.getSystemInfoSync().windowHeight;
			this.winHeight = (height - 150);			
			this._requestPageList(true);
		},	
		methods:{
			// 参数
			_requestPageList(isLoadMore = false, callback) {
			  if(!isLoadMore){
				this.allTabList=[]; // 全部       
				this.pageNo= 1;
				
			  }
			  let opt = {
				pageNo :this.pageNo,				
				token:uni.getStorageSync('userInfo').token
			  }    
			  this._requestPageListCom("virtualTaskList", opt, callback);
			},
			// 列表接口
			_requestPageListCom(url, params, callback) {    
			  this.$http.RecomMenberLog(params).then(res => {
				if (res.resCode == "9999") {
				  let oldList = [];
				  oldList = this.allTabList;       
				  const newGoodsList = res.data.list
				  const allData = [...oldList, ...newGoodsList]
				  // console.log(allData,'allData')     
				  this.allTabList=allData
				  this.group_total=res.data.count
				  if(callback && typeof callback === 'function'){
					callback()
				  }
				}
			  })
			},			  
			// 上拉加载  滚动到底部/右边时触发
			allLoadMore(e){
				let _self = this;
				if (this._allLoadMore) return
				this._allLoadMore = true;
				this.pageNo= ++_self.pageNo				
				this._requestPageList(true, () => {
				  _self._allLoadMore = false;
				});
			},
			
			// 下拉刷新接口
			onAllRefresh() {
			 // 开启下拉自定义样式
				this.triggered = true;
                this.pageNo=1;
				this._requestPageList(false, () => {
					// 当处理完数据刷新后，wx.stopPullDownRefresh可以停止当前页面的下拉刷新
					this.triggered = false;
				});    
			}	
		  },
		onShow(){	
		}
	}
</script>

<style>
	@import "./index.css";
</style>